<%@ page import="com.situ.web.pojo.Teacher" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Gao
  Date: 2024/8/5
  Time: 11:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="static/bootstrap-3.4.1-dist/css/bootstrap.css">
</head>
<body>
    <%
        List<Teacher> list = (List<Teacher>) request.getAttribute("list");
    %>
    <a href="/teacher_add.jsp">添加</a>
    <table class="table table-striped table-bordered table-hover table-condensed">
        <tr class="success">
            <td>ID</td>
            <td>名字</td>
            <td>年龄</td>
            <td>地址</td>
            <td>删除</td>
            <td>编辑</td>
        </tr>
        <%
            for (Teacher teacher : list) {
        %>
                <tr>
                    <td><%=teacher.getId()%></td>
                    <td><%=teacher.getName()%></td>
                    <td><%=teacher.getAge()%></td>
                    <td><%=teacher.getAddress()%></td>
                    <%--<td><a href="/deleteTeacher?id=<%=teacher.getId()%>">删除</a></td>--%>
                    <td><a href="javascript:void(0)" onclick="deleteById(<%=teacher.getId()%>)">删除</a></td>
                    <td><a href="/teacher?method=toUpdate&id=<%=teacher.getId()%>">编辑</a></td>
                </tr>
        <%
            }
        %>
    </table>

    <script>
        function deleteById(id) {
            //var: variable
            var isDelete = confirm('您确认要删除么？');
            if (isDelete) {
                location.href = '/teacher?method=deleteById&id=' + id;
            }
        }
    </script>
</body>
</html>
